#include "MaterialCameraNodeModel.h"

#include "MaterialGraph/Pin/MaterialGraphPinModel.h"
#include "Object/NewObject.h"

void RMaterialCameraNodeModel::FirstTimeInitializeObject()
{
    auto CameraScenePositionPin = NewObject<RMaterialGraphPinModel>(this);
    CameraScenePositionPin->bIsOutput = true;
    CameraScenePositionPin->ValueType = EMaterialGraphValueType::Vector3D;
    Outputs.Add(CameraScenePositionPin);

    auto CameraSceneForwardDirectionPin = NewObject<RMaterialGraphPinModel>(this);
    CameraSceneForwardDirectionPin->bIsOutput = true;
    CameraSceneForwardDirectionPin->ValueType = EMaterialGraphValueType::Vector3D;
    Outputs.Add(CameraSceneForwardDirectionPin);

    auto CameraSceneRightDirectionPin = NewObject<RMaterialGraphPinModel>(this);
    CameraSceneRightDirectionPin->bIsOutput = true;
    CameraSceneRightDirectionPin->ValueType = EMaterialGraphValueType::Vector3D;
    Outputs.Add(CameraSceneRightDirectionPin);

    auto CameraSceneUpDirectionPin = NewObject<RMaterialGraphPinModel>(this);
    CameraSceneUpDirectionPin->bIsOutput = true;
    CameraSceneUpDirectionPin->ValueType = EMaterialGraphValueType::Vector3D;
    Outputs.Add(CameraSceneUpDirectionPin);



}

CString RMaterialCameraNodeModel::GenerateExpression()
{
    CString Result;
    if(Outputs[0]->HasValidLink())
    {
        Result+=
            U"vec3 "+Outputs[0]->UniqueOutputPinName+U" = SceneBuffer.CameraPosition;\n";
    }

    if(Outputs[1]->HasValidLink())
    {
        Result+=
            U"vec3 "+Outputs[1]->UniqueOutputPinName+U" = SceneBuffer.CameraForwardDirection;\n";
    }

    if(Outputs[2]->HasValidLink())
    {
        Result+=
            U"vec3 "+Outputs[2]->UniqueOutputPinName+U" = SceneBuffer.CameraRightDirection;\n";
    }

    if(Outputs[3]->HasValidLink())
    {
        Result+=
            U"vec3 "+Outputs[3]->UniqueOutputPinName+U" = SceneBuffer.CameraUpDirection;\n";
    }

    return Result;

}
